ObservableCollectionEx
Represents an observable collection with extended methods, including range operations.
Implementa: IListEx<T>, IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable, ICollectionEx<T>, IList, ICollection, INotifyCollectionChanged, INotifyPropertyChanged
Propriedades
public int Count { get; }
value = observableCollectionEx.Count
Gets the number of elements contained in the collection.
public bool IsReadOnly { get; }
value = observableCollectionEx.IsReadOnly
Gets a value indicating whether the collection is read-only.
public TItem Item { get; set; }
value = observableCollectionEx.Item
observableCollectionEx.Item = value
Gets or sets the element at the specified index.
- index
- The zero-based index of the element to get or set.
Retorna: The element at the specified index.
Métodos
public virtual void Add(TItem item)
observableCollectionEx.Add(item)
Adds an item to the collection.
- item
- The item to add.
public virtual void AddRange(IEnumerable<TItem> items)
observableCollectionEx.AddRange(items)
Adds a range of items to the collection.
- items
- The items to add.
public virtual void Clear()
observableCollectionEx.Clear()
Removes all items from the collection.
public bool Contains(TItem item)
result = observableCollectionEx.Contains(item)
Determines whether the collection contains a specific value.
- item
- The item to locate.
Retorna: true if the item is found; otherwise, false.
public void CopyTo(TItem[] array, int arrayIndex)
observableCollectionEx.CopyTo(array, arrayIndex)
Copies the elements of the collection to an array, starting at a particular index.
- array
- The destination array.
- arrayIndex
- The zero-based index at which copying begins.
public IEnumerator<TItem> GetEnumerator()
result = observableCollectionEx.GetEnumerator()
Returns an enumerator that iterates through the collection.
Retorna: An enumerator for the collection.
public int IndexOf(TItem item)
result = observableCollectionEx.IndexOf(item)
Determines the index of a specific item in the collection.
- item
- The item to locate.
Retorna: The index of the item if found; otherwise, -1.
public void Insert(int index, TItem item)
observableCollectionEx.Insert(index, item)
Inserts an item into the collection at the specified index.
- index
- The index at which the item should be inserted.
- item
- The item to insert.
private void OnCollectionChanged(NotifyCollectionChangedEventArgs args)
observableCollectionEx.OnCollectionChanged(args)
Raises the CollectionChanged event.
- args
- Details about the change.
private void OnCollectionReset()
observableCollectionEx.OnCollectionReset()
Raises the CollectionChanged event with a reset action.
protected void OnPropertyChanged(string propertyName)
observableCollectionEx.OnPropertyChanged(propertyName)
Raises the PropertyChanged event.
- propertyName
- The name of the property that changed.
private void OnRemove(IList<TItem> items, int index)
observableCollectionEx.OnRemove(items, index)
Raises the collection changed event for a removal.
- items
- The items removed.
- index
- The index from which the items were removed.
protected virtual void ProcessCollectionChanged(IEnumerable<NotifyCollectionChangedEventHandler> subscribers, NotifyCollectionChangedEventArgs args)
observableCollectionEx.ProcessCollectionChanged(subscribers, args)
Processes the NotifyCollectionChangedEventHandler subscribers.
- subscribers
- The collection of subscribers.
- args
- Details about the change.
public virtual bool Remove(TItem item)
result = observableCollectionEx.Remove(item)
Removes the first occurrence of a specific item from the collection.
- item
- The item to remove.
Retorna: true if the item was successfully removed; otherwise, false.
public void RemoveAt(int index)
observableCollectionEx.RemoveAt(index)
Removes the item at the specified index of the collection.
- index
- The zero-based index of the item to remove.
public virtual void RemoveRange(IEnumerable<TItem> items)
observableCollectionEx.RemoveRange(items)
Removes a range of items from the collection.
- items
- The items to remove.
public virtual int RemoveRange(int index, int count)
result = observableCollectionEx.RemoveRange(index, count)
Removes a specified range of items starting at a given index.
- index
- The starting index.
- count
- The number of items to remove.
Retorna: The number of removed items.
Eventos
public event Action<IEnumerable<TItem>> AddedRange
observableCollectionEx.AddedRange += handler
Occurs after a range of items has been added to the collection.
public event NotifyCollectionChangedEventHandler CollectionChanged
observableCollectionEx.CollectionChanged += handler
Occurs when the collection changes.
public event PropertyChangedEventHandler PropertyChanged
observableCollectionEx.PropertyChanged += handler
Occurs when a property value changes.
public event Action<IEnumerable<TItem>> RemovedRange
observableCollectionEx.RemovedRange += handler
Occurs after a range of items has been removed from the collection.